package com.thuanhoang.boo.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.thuanhoang.boo.R;
import com.thuanhoang.boo.model.ObjMerchantCategory;

public class MenuListAdapter extends ArrayAdapter<ObjMerchantCategory> {
	private final Context context;
	private final ArrayList<ObjMerchantCategory> list_item;
	private LayoutInflater inflater;
	public  int TAG;

	public MenuListAdapter(Context context, ArrayList<ObjMerchantCategory> items) {
		super(context, 0, items);
		this.context = context;
		this.list_item = items;
		inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

		// Log.e("", "object unread " + MainActivity.ListUnread.size());
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		ObjMerchantCategory item = list_item.get(position);
		View rowView = convertView;
		rowView = inflater.inflate(R.layout.menu_item, null);

		final TextView merchCatName = (TextView) rowView
				.findViewById(R.id.productMerchCatName);
		merchCatName.setText(item.getProductMerchCatName());
		if (position== this.TAG ) {
			rowView.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.menu_item_selector));               
		} else {
			rowView.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.menuregion_selector));            
		}
		return rowView;
	}

}
